﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MvcShop.Models.ViewDataModels
{
    public class OrdersViewData:ViewDataBase
    {
        #region ==== Property =====
        public int PageIndex { get; set; }
        public int Count { get; set; }
        public int Total { get; set; }
        public string KeyWord { get; set; }

        public Orders Orders { get; set; }
        public IEnumerable<Orders> Orderses { get; set; }

        public OrdersInfo OrdersInfo { get; set; }
        public IEnumerable<OrdersInfo> OrdersInfos { get; set; }

        public Deliver Deliver { get; set; }
        public IEnumerable<Deliver> Delivers { get; set; }
        #endregion

        #region ==== Methods ====
        public OrdersViewData WithPageIndex(int pageIndex)
        {
            this.PageIndex = pageIndex;
            return this;
        }

        public OrdersViewData WithCount(int count)
        {
            this.Count = count;
            return this;
        }

        public OrdersViewData WithTotal(int pageSize)
        {
            this.Total = Math.Max((this.Count + pageSize - 1) / pageSize, 1); ;
            return this;
        }

        public OrdersViewData WithKeyWord(string keyWord)
        {
            this.KeyWord = keyWord;
            return this;
        }

        public OrdersViewData WithOrders(Orders orders)
        {
            this.Orders = orders;
            return this;
        }

        public OrdersViewData WithOrderses(IEnumerable<Orders> orderses)
        {
            this.Orderses = orderses;
            return this;
        }

        public OrdersViewData WithOrdersInfo(OrdersInfo ordersInfo)
        {
            this.OrdersInfo = ordersInfo;
            return this;
        }

        public OrdersViewData WithOrdersInfos(IEnumerable<OrdersInfo> ordersInfos)
        {
            this.OrdersInfos = ordersInfos;
            return this;
        }

        public OrdersViewData WithDeliver(Deliver deliver)
        {
            this.Deliver = deliver;
            return this;
        }

        public OrdersViewData WithDelivers(IEnumerable<Deliver> delivers)
        {
            this.Delivers = delivers;
            return this;
        }
        #endregion
    }

    public static class OrdersView
    {
        public static OrdersViewData Data { get { return new OrdersViewData(); } }
    }
}
